import 'package:flutter/cupertino.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:oktoast/oktoast.dart';

import 'log_util.dart';

/// String 扩展类
extension StringToast on String {
  void toast({ToastPosition? position}) {
    showToast(this,
        position: position,
        textPadding: EdgeInsets.only(top: 6, bottom: 8, left: 10, right: 10));
  }
}

extension StringLogd on String {
  void logd() {
    LogUtil().d(this);
  }
}

extension StringLogw on String {
  void logw() {
    LogUtil().w(this);
  }
}

extension StringLogi on String {
  void logi() {
    LogUtil().i(this);
  }
}

extension StringLoge on String {
  void loge() {
    LogUtil().e(this);
  }
}

///字符串非空判断（只支持了字符串）
extension StringIsEmpty on dynamic {
  bool strIsEmpty() {
    if (this == null || this == "null" || this.length == 0) {
      return true;
    } else {
      return false;
    }
  }
}
